<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    function half(num, target) {
        let left = 0
        let right = num.length-1

        while(left<=right) {
            const mid = Math.floor((left + right) /2)
            const middle = num[mid]
            if(middle === target) {
                return mid
            } else if(middle < target) {
                left = mid + 1
            } else {
                right = mid-1
            }

        }

        return -1

    }
</script>
<body>
    
</body>
</html>